package com.ruoyi.system.entity;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.ArrayList;
import java.util.Date;
import java.io.Serializable;
import java.util.List;

/**
 * (SisApprove)实体类
 *
 * @author makejava
 * @since 2023-08-01 10:17:49
 */
public class SisApprove implements Serializable {
    private static final long serialVersionUID = 268593113109753760L;
    
    private Integer id;
    /**
     * 附件名称
     */
    private String fileName;
    /**
     * 附件路径
     */
    private String fileUrl;
    /**
     * 明细表
     */
    private String detaileds;
    /**
     * 审批阶段
     */
    private Integer phase;
    /**
     * 类型(1-切除 2-恢复)
     */
    private String approveType;
    /**
     * 审批状态（审批中 已通过 已驳回）
     */
    private String state;

    private String createUserName;

    private Integer createUserId;



    private String signUrl;

    private String explainInfo;

    private String status;

    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    /**
     * 修改时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date updateTime;

    private List<SisPhase> sisPhases;

    private String phaseUserName;

    private String startTime;

    private String endTime;

    private String deviceName;

    public String getDeviceName() {
        if (StrUtil.isEmpty(deviceName)) {
            List<String> deviceNames = new ArrayList<>();
            if (StrUtil.isNotEmpty(detaileds)) {
                JSONArray objects = JSONUtil.parseArray(detaileds);
                for (Object object : objects) {
                    JSONObject jsonObject = JSONUtil.parseObj(object);
                    String deviceName = jsonObject.getStr("deviceName");
                    deviceNames.add(deviceName);
                }
            }
            deviceName = CollUtil.join(deviceNames,"、");
        }
        return deviceName;
    }

    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public String getPhaseUserName() {
        return phaseUserName;
    }

    public void setPhaseUserName(String phaseUserName) {
        this.phaseUserName = phaseUserName;
    }

    public String getExplainInfo() {
        return explainInfo;
    }

    public void setExplainInfo(String explainInfo) {
        this.explainInfo = explainInfo;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getSignUrl() {
        return signUrl;
    }

    public void setSignUrl(String signUrl) {
        this.signUrl = signUrl;
    }

    public String getCreateUserName() {
        return createUserName;
    }

    public void setCreateUserName(String createUserName) {
        this.createUserName = createUserName;
    }

    public Integer getCreateUserId() {
        return createUserId;
    }

    public void setCreateUserId(Integer createUserId) {
        this.createUserId = createUserId;
    }

    public List<SisPhase> getSisPhases() {
        return sisPhases;
    }

    public void setSisPhases(List<SisPhase> sisPhases) {
        this.sisPhases = sisPhases;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    public String getFileUrl() {
        return fileUrl;
    }

    public void setFileUrl(String fileUrl) {
        this.fileUrl = fileUrl;
    }

    public String getDetaileds() {
        return detaileds;
    }

    public void setDetaileds(String detaileds) {
        this.detaileds = detaileds;
    }

    public Integer getPhase() {
        return phase;
    }

    public void setPhase(Integer phase) {
        this.phase = phase;
    }

    public String getApproveType() {
        return approveType;
    }

    public void setApproveType(String approveType) {
        this.approveType = approveType;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

}

